I've finally made it work with the trick I gave in the previous message. However I had to apply the renewal date not just for master manifest request, but also for all child manifests. It's unclear why "default" playback session cannot do it itself when redirecting child manifest requests, perhaps it could not make an educated guess about type of the asset (VOD/live) without having the information from master manifest, but my implementation doesn't rely on it either:
if let httpResonse = response as? HTTPURLResponse, let expirationValue = httpResonse.value(forHTTPHeaderField: "Expires") {
let dateFormatter = DateFormatter()
dateFormatter.locale = Locale(identifier: "en_US_POSIX")
dateFormatter.dateFormat = "EEE, dd MMM yyyy HH:mm:ss zzz"
if let expirationDate = dateFormatter.date(from: expirationValue) {
let renewDate = max(expirationDate, Date(timeIntervalSinceNow: 8))
contentInformationRequest.renewalDate = renewDate
}
}
This line let renewDate = max(expirationDate, Date(timeIntervalSinceNow: 8)) adds 8 seconds grace period for the player to load videos. Otherwise it does not keep up with the pace of renewals, and video loads in poor quality.
Topic:
App & System Services
SubTopic:
Core OS
Tags: